Add support to export ML-DSA key-pairs in seed format #2194
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues:
Resolves #CryptoAlg-2918
#ACCP-130
Description of changes:
Support the ability to export ML-DSA key seeds. We modify the core algorithm implementation to store the
seed
used during key generation. This will allow the key pair to be reconstructed at a later stage from just the seed.This is performed within
ml_dsa_keypair
, which has been modified to accept an addition argumentseed
that is a pointer to output array ofML_DSA_SEEDBYTES
bytes.These changes bubble up to the
ml_dsa.c
definitions of keygen, that are now modified to support the provided buffer to store the seed:We store the seed in the
PQDSA_KEY
struct duringpkey_pqdsa_keygen
:To export, this PR supports:
EVP_marshal_private_key
to export full format private keyEVP_marshal_private_key_v2
to export seed format private keyEVP_PKEY_get_raw_private_key
to export raw format in full/seed form, depending on size provided (this could be a new API)FIPS Compliance: I'm glad you're asking, yes this is compliant with FIPS, NIST have published PQC FAQs specifically to address this exact implementation: https://csrc.nist.gov/Projects/post-quantum-cryptography/faqs#Rdc7.
Performance Impact
Converting to seed-based storage for both public and private keys yields the following improvements:
Converting to seed-based storage for private keys yields the following improvements:
The proposed seed-based approach achieves an average storage reduction of 99.4% across all ML-DSA variants.
Call-outs:
Once we have alignment on the EVP API functionality, I will add documentation.
Testing:
Added new test suite
Marshalv2ParseSeed
for parsing as well as additional test for parsing seeds inRawFunctions
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.